﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Domain;

namespace SharedGenomics.Workbench.PresentationModel
{
    public class FileSchemaColumnDTO
    {
        public FileSchemaColumnDTO(FileSchemaColumn column)
        {
            this.Column = column;
        }

        public override string ToString()
        {
            return this.Column.Label ?? this.Column.Name;
        }

        public string Name
        {
            get { return this.Column.Name; }
        }

        public string Label
        {
            get { return this.Column.Label; }
        }

        public IList<string> Values
        {
            get
            {
                return this.ColumnIsNominal
                    ? ((NominalFileSchemaColumn)this.Column).Values.Select(c => c.Label ?? c.Value).ToList()
                    : new List<string>();
            }
        }

        public IList<string> MissingValues
        {
            get
            {
                return this.ColumnIsNominal
                    ? ((NominalFileSchemaColumn)this.Column).MissingValues.ToList()
                    : new List<string>();
            }
        }

        private FileSchemaColumn Column { get; set; }
        private bool ColumnIsNominal
        {
            get { return this.Column is NominalFileSchemaColumn; }
        }
    }
}
